namespace YogoPop.Component.Auth;

public class YogoSessionContextBase : IYogoSessionContext
{
    public virtual string ContextID { get; set; }

    public virtual string TypeOfTokenProvider { get; set; }

    public virtual OperationTypeEnum OperationType { get; set; }

    public virtual void RestoreContextID() { }

    public void Save()
    {
        var authSettings = InjectionContext.Resolve<AuthSettings>();
        using (var cache = authSettings.ResolveCache<ICache4Redis>())
        {
            cache.Set(authSettings.SessionPrefix + ContextID, this.ToJson(), TimeSpan.FromMinutes(5));
        }
    }
}